package cn.gson.crm.model.pojos;

import javax.persistence.*;
import java.sql.Time;
import java.sql.Timestamp;
import java.util.Objects;

@Entity
@Table(name = "Customer_service", schema = "CRM", catalog = "")
public class CustomerService {
    private long cusId;
    private String cusContent;
    private Long cusCharge;
    private Timestamp cusTime;
    private String cusFeedback;
    private String cusDesc;
    private Customer customerByCustomerId;
    private Employee employee;
    @ManyToOne(cascade={CascadeType.MERGE,CascadeType.REFRESH},optional=false)//可选属性optional=false,表示author不能为空。删除文章，不影响用户
    @JoinColumn(name = "cus_charge",insertable = false,updatable = false)//设置在article表中的关联字段(外键)
    public Employee getEmployee() {
        return employee;
    }

    public void setEmployee(Employee employee) {
        this.employee = employee;
    }
    @Id
    @Column(name = "cus_id")
    @GeneratedValue(generator = "seq",strategy = GenerationType.SEQUENCE)
    //定义一个序列生成器
    @SequenceGenerator(name = "seq",sequenceName = "crm",
            initialValue = 1,allocationSize = 1)
    public long getCusId() {
        return cusId;
    }

    public void setCusId(long cusId) {
        this.cusId = cusId;
    }

    @Basic
    @Column(name = "cus_content")
    public String getCusContent() {
        return cusContent;
    }

    public void setCusContent(String cusContent) {
        this.cusContent = cusContent;
    }

    @Basic
    @Column(name = "cus_charge")
    public Long getCusCharge() {
        return cusCharge;
    }

    public void setCusCharge(Long cusCharge) {
        this.cusCharge = cusCharge;
    }

    @Basic
    @Column(name = "cus_time")
    public Timestamp getCusTime() {
        return cusTime;
    }

    public void setCusTime(Timestamp cusTime) {
        this.cusTime = cusTime;
    }

    @Basic
    @Column(name = "cus_feedback")
    public String getCusFeedback() {
        return cusFeedback;
    }

    public void setCusFeedback(String cusFeedback) {
        this.cusFeedback = cusFeedback;
    }

    @Basic
    @Column(name = "cus_desc")
    public String getCusDesc() {
        return cusDesc;
    }

    public void setCusDesc(String cusDesc) {
        this.cusDesc = cusDesc;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        CustomerService that = (CustomerService) o;
        return cusId == that.cusId &&
                Objects.equals(cusContent, that.cusContent) &&
                Objects.equals(cusCharge, that.cusCharge) &&
                Objects.equals(cusTime, that.cusTime) &&
                Objects.equals(cusFeedback, that.cusFeedback) &&
                Objects.equals(cusDesc, that.cusDesc);
    }

    @Override
    public int hashCode() {
        return Objects.hash(cusId, cusContent, cusCharge, cusTime, cusFeedback, cusDesc);
    }

    @ManyToOne
    @JoinColumn(name = "customer_id", referencedColumnName = "customer_id")
    public Customer getCustomerByCustomerId() {
        return customerByCustomerId;
    }

    public void setCustomerByCustomerId(Customer customerByCustomerId) {
        this.customerByCustomerId = customerByCustomerId;
    }
}
